using System;

namespace IValidate
{
	public class ValidateDateAttribute : ModelValidatorBaseImpl
	{
		public ValidateDateAttribute(string errorMessage)
			: this(errorMessage, false)
		{
		}
		public ValidateDateAttribute(string errorMessage, bool required)
			: base(errorMessage, required)
		{
		}
		public override bool Validate(object value)
		{
			if (value == null) return false;
			if (String.IsNullOrEmpty(value.ToString())) return false;
			DateTime date;
			return DateTime.TryParse(value.ToString(), out date);
		}
	}
}
